package com.itcast.manager3.C_service;

import com.itcast.manager3.D_dao.ShareholderDao;
import com.itcast.manager3.tomian.ShareholderTomain;

import java.util.ArrayList;

public class ShareholderService {
    ShareholderDao shd = new ShareholderDao();

    public boolean isExists(String id) {
        ArrayList<ShareholderTomain> list = shd.getShareholdList();
        for (int i = 0; i < list.size(); i++) {
            ShareholderTomain sha = list.get(i);
            if ( sha.getId().equals(id)) {
                return true;
            }
        }
        return false;
    }

    public ArrayList<ShareholderTomain> findShareholder() {
        ArrayList<ShareholderTomain> list = shd.getShareholdList();
        return list;
    }

    public void addShareholder(ShareholderTomain sdd) {
        shd.addShareholder(sdd);
    }

    public void deleteShareholder(String id) {
        shd.deleteShareholder(id);
    }

    public void updateShareholder(ShareholderTomain sto) {
        shd.updateShareholder(sto);
    }
}
